<template>
  <div class="contentShadow">
    <el-upload
        :auto-upload="false"
        :before-upload="beforeUpload"
        :on-change="uploadFile"
        style="display: inline-block;"
    >
      <el-button size="small" type="primary">导出学生成绩</el-button>
    </el-upload>

  </div>
</template>

<script>

import {uploadGrade} from "@/api/upload";

export default {
  methods: {
    beforeUpload(file) {
      console.log(file);
    },
    uploadFile(file) {
      const formData = new FormData();
      formData.append('file', file.raw);

      // 发起上传请求
      uploadGrade(formData).then(response => {
        alert('文件上传成功');
        // 处理上传成功的逻辑
      }).catch(error => {
        alert('文件上传失败');
        // 处理上传失败的逻辑
      });
    }
  },
  data() {
    return {
      // selectedFile: null
    };
  }
};
</script>
